<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'article-add', //页面标示
    'pagename' => '新增文章', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min','content/webuploader'), //加载的css样式表
    'myjs'     => array('content/jquery.smoothConfirm'), //加载的js脚本
    'footerjs' => array('content/fuelux/fuelux', '../ueditor/editor_config', '../ueditor/editor.min','content/combodate/moment.min','../jquery-ui/js/jquery-ui-1.10.0.custom.min'),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>
.w80{width:80px;text-align:center;}
.hide{display:none;}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <section class="main padder"> 
    <div class="clearfix"> 
     <h4><i class="fa fa-edit"></i>新增文章</h4> 
    </div> 
    <div class="row"> 
     <div class="col-sm-12"> 
      <section class="panel"> 
       <div class="panel-body"> 
        <form class="form-horizontal" id="goodsAddForm" method="post" > 

        <div class="form-group">
          <label class="col-sm-1 control-label">所属分类</label>
          <div class="col-sm-2">
              <select id="cid" name="cid" class="form-control">
                  <option value="-1">选择分类</option>
                  <?php foreach ($article_type as $k => $v): ?>
                  <option value="<?php echo $k ?>"><?php echo $v?></option>
                  <?php endforeach ?>
              </select>
          </div>
        </div>

        <div class="form-group"> 
          <label class="col-sm-1 control-label">文章标题</label> 
          <div class="col-sm-3"> 
            <input type="text" name="title" id="title" placeholder="文章标题" class="form-control" data-required="true"  />
          </div> 
        </div> 

        <div class="form-group"> 
            <label class="col-sm-1 control-label">文章详情</label> 
            <div class="col-sm-5"> 
              <script type="text/plain" id="editor"></script>
            </div>
        </div>

        <style>.row .checkbox{float:left}</style>

        <div class="form-group"> 
          <label class="col-sm-1 control-label">是否上线</label>
            <div class="row">
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="status" checked="checked" value="1" /> <i class="fa fa-circle-o"></i>上线</label></div>
              <div class="col-xs-1 radio m-l-large"><label class="radio-custom"> <input type="radio" name="status" value="0" /> <i class="fa fa-circle-o"></i>下线</label></div>
            </div>
         </div>

         <div class="form-group"> 
          <div class="col-sm-9 col-lg-offset-3"> 
            <input type="hidden" name="content" id="goods_body">
            <div class="col-sm-1">
              <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
            </div>
            <button type="button" class="btn btn-white col-md-offset-1">取消</button> 
          </div> 
         </div> 
        </form> 
       </div> 
      </section>
     </div> 
    </div> 
   </section> 

  </section> 
  <!--/ content --> 
<!--主体 结束-->
<style type="text/css">
  .removeFile{float:left;margin:115px 0 20px -85px;cursor: pointer;color: #5191d1;}
</style>
<script>     
var fixedImagePath      = '';
var uploadUrl           = "<?php echo U('goods/upload');?>";
var UEDITOR_HOME_URL = '<?php echo LOCAL_PUBLIC_PATH; ?>ueditor/';
$(function(){

  var msg_editor = new UE.ui.Editor({initialFrameWidth: 690, initialFrameHeight:320});
  msg_editor.render("editor");

  $('#goodsAddForm').submit(function(){

    $("#goods_body").val(msg_editor.getContent());
    
    if($('#cid').val() == -1) {
      Msg.error('请选择文章分类');
      resetSubmit("#sub-ok",'提交');
      return false;
    }

    if (!$('#title').val()){
      Msg.error('请输入文章标题');
      resetSubmit("#sub-ok",'提交');
      return false;
    }

    Msg.loading();
    $.post('<?php echo U('article/add');?>',$(this).serialize(),function(result){
      Msg.hide();
      resetSubmit("#sub-ok",'提交');
      if (result.status==1){
      self.location.href = '<?php echo U("content/article/index"); ?>';
    }else{
      Msg.error(result.info);
    }
    },'json');
    return false;
  });
})
</script>
<?php include getTpl('footer', 'public'); ?>